package com.JWH_TV.utils

import androidx.recyclerview.widget.DiffUtil
import com.JWH_TV.domain.Program

class ProgramDiffCallback(
    private val oldList: List<Program>,
    private val newList: List<Program>
) : DiffUtil.Callback() {

    override fun getOldListSize(): Int = oldList.size

    override fun getNewListSize(): Int = newList.size

    override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
        // 判断两个项是否是同一项，通常是通过 ID 来判断
        return oldList[oldItemPosition].urlId == newList[newItemPosition].urlId
    }

    override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
        // 判断两个项的内容是否相同
        return oldList[oldItemPosition] == newList[newItemPosition]
    }
}